import { Component, OnInit } from '@angular/core';
import { NewsService } from '../../service/news.service';
import { ActivatedRoute, Router } from '@angular/router';
import { News } from '../../model/news';

@Component({
  selector: 'app-newslistforuser',
  templateUrl: './newslistforuser.component.html',
  styleUrls: ['./newslistforuser.component.css']
})
export class NewslistforuserComponent implements OnInit {
  n1:Array<News>;
  constructor(  
    private newsservice:NewsService,
    private router:Router
    ) { }

    ngOnInit() {
      this.loadNewsList();
      }

    private loadNewsList(){
      this.n1=new Array();
      this.newsservice.getNewsList().then((data:any)=>{
      this.n1=data;
      })
    }

    toDetail(id:string){
      this.router.navigate(['detail',id]);
      }
  




}
